package com.myacg.platform.ui.component.window;

import java.awt.*;

import javax.swing.JFrame;

import com.myacg.core.entity.Point;
import com.myacg.platform.ui.component.pane.DefaltPane;
import com.myacg.platform.ui.component.pane.DragPane;
import com.myacg.platform.ui.component.pane.MovePane;

public class DefaultFrame extends JFrame {
		private int width;
		private int height;
		//获取屏幕宽高
		private Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
		public DefaultFrame(int width,int height){
			this.width=width;
			this.height=height;
			this.setLayout(null);
			this.setBounds((screen.width-width)/2,(screen.height-height)/2, width, height);
			//添加对应的事件
			this.setVisible(true);
			this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			 
		}
		/**
		 * 加入一个组件到某个位置
		 * @param comp
		 * @param x
		 * @param y
		 */
		public void addBody(DefaltPane  comp,int x, int y){
			this.add(comp);
			Dimension size = comp.getSize();
			comp.setBounds(x, y,size.width ,size.height);
		}
		
		public static void main(String[] args) throws InterruptedException {
			DefaultFrame defaultFrame=	new DefaultFrame(1500,1000);
			//加入一个组件
			//defaultFrame.addBody(new DragPane(50, 50,new Color(200, 200, 200, 50)), 150, 50);
			//加入一个组件
			//defaultFrame.addBody(new DragPane(100, 100,Color.white), 250, 50);
			
			
			//加入一个组件
			//带反弹的
			MovePane p1 = new MovePane(50, 50,MovePane.MOVE_TYPE_SPRINGMOTION);
			
			MovePane p2 = new MovePane(100, 100,MovePane.MOVE_TYPE_LINEMOVE);
			
			MovePane p3 = new MovePane(50, 50,MovePane.MOVE_TYPE_SPRINGBACK);
			
			MovePane p4 = new MovePane(30, 30, MovePane.MOVE_TYPE_Circular);
			//defaultFrame.addBody(p1, 150, 50);
			//加入一个组件
			//defaultFrame.addBody(p2, 50, 200);
			///defaultFrame.addBody(p3, 300, 50);
			defaultFrame.addBody(p4, 300, 50);
			//p1.moveTo(new Point(150, 200), 10, 130);
			//p2.moveTo(new Point(250, 200), 0, 20);
			
			// p3.moveTo(new Point(300,200), 10,0);
			
			p4.moveTo(new Point(300,200), 0,10);
		}
}
